Skip to content

Manage sensitivity parameters with node built#3764

Open
EtienneLt wants to merge 12 commits intomainfrom
manage-sensitivity-parameters-with-node-built
Open

Manage sensitivity parameters with node built#3764
EtienneLt wants to merge 12 commits intomainfrom
manage-sensitivity-parameters-with-node-built

Conversation

@EtienneLt
Copy link
Copy Markdown
Contributor

@EtienneLt EtienneLt commented Feb 26, 2026

PR Summary

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt self-assigned this Feb 26, 2026
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt changed the title Wip Manage sensitivity parameters with node built Manage sensitivity parameters with node built Feb 27, 2026
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

This pull request migrates build status constants and components from local definitions to external imports from @gridsuite/commons-ui. The BUILD_STATUS enum is removed from local constants, replaced with BuildStatus across type definitions and component logic. The local BuildStatusChip component is deleted and replaced with the external version. Translation keys for build statuses are removed.

Changes

Cohort / File(s) Summary
Type definitions
src/components/graph/tree-node.type.ts, src/components/graph/util/model-functions.ts, src/services/study/tree-subtree.ts
Replaced local BUILD_STATUS type with BuildStatus from @gridsuite/commons-ui; updated type annotations and function parameter types accordingly.
Graph UI & actions
src/components/graph/menus/create-node-menu.tsx, src/components/graph/menus/root-network/unbuild-all-nodes-button.tsx, src/components/graph/network-modification-tree-model.ts, src/components/graph/nodes/build-button.tsx, src/components/graph/nodes/network-modification-node.tsx
Switched runtime comparisons and conditional logic to use BuildStatus from commons; replaced local BuildStatusChip import with external one; adjusted props/types where needed.
Removed component
src/components/graph/nodes/build-status-chip.tsx
Deleted local BuildStatusChip implementation and its default export; functionality expected from @gridsuite/commons-ui.
Other components & panes
src/components/network-modification-tree-pane.jsx, src/components/parameters-tabs.tsx, src/components/results/common/computation-report-viewer.tsx, src/components/study-container.jsx
Updated imports and comparisons to use BuildStatus from commons; added currentNode usage and prop passing in parameters-tabs.tsx.
Constants & translations
src/components/network/constants.ts, src/translations/en.json, src/translations/fr.json
Removed local exported BUILD_STATUS enum; removed corresponding build-status translation keys from English and French JSON files.

Suggested reviewers

  • TheMaskedTurtle
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Manage sensitivity parameters with node built' is partially related to the changeset, referring to the sensitivity parameters aspect but not the main refactoring effort of migrating BUILD_STATUS and BuildStatusChip from local code to commons-ui.
Description check ✅ Passed The description clearly outlines the main objectives: moving BUILD_STATUS enum to commons-ui, moving build-status-chip to commons-ui, and adding globalBuildStatus parameter to sensitivity parameters, which aligns well with the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/parameters-tabs.tsx (1)

70-70: ⚠️ Potential issue | 🟡 Minor

Inconsistent migration: Still using local BUILD_STATUS instead of BuildStatus from commons-ui.

This file imports BUILD_STATUS from './network/constants' (line 70) and uses it in the SecurityAnalysisParametersInline component (lines 319-321). According to the PR objectives, BUILD_STATUS is being moved to @gridsuite/commons-ui, and other files in this PR have already migrated to use BuildStatus from that package.

🔧 Proposed fix to complete the migration
-import { BUILD_STATUS } from './network/constants';

Update the import at line 52 to include BuildStatus:

 import {
     ComputingType,
     DynamicMarginCalculationInline,
     ...
+    BuildStatus,
 } from '@gridsuite/commons-ui';

Then update lines 319-321:

 isBuiltCurrentNode={
-    currentNodeBuildStatus !== BUILD_STATUS.NOT_BUILT &&
-    currentNodeBuildStatus !== BUILD_STATUS.BUILDING
+    currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
+    currentNodeBuildStatus !== BuildStatus.BUILDING
 }

Also applies to: 319-321

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/parameters-tabs.tsx` at line 70, The file still imports the
local BUILD_STATUS constant and uses it in SecurityAnalysisParametersInline;
replace the local import and usage with the canonical BuildStatus from
`@gridsuite/commons-ui`: update the import to import { BuildStatus } from
'@gridsuite/commons-ui' instead of BUILD_STATUS from './network/constants', then
update the SecurityAnalysisParametersInline code that references BUILD_STATUS
(lines around the SecurityAnalysisParametersInline component) to use BuildStatus
(matching the enum/shape exported by commons-ui) so the component aligns with
the other migrated files.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/components/parameters-tabs.tsx`:
- Line 70: The file still imports the local BUILD_STATUS constant and uses it in
SecurityAnalysisParametersInline; replace the local import and usage with the
canonical BuildStatus from `@gridsuite/commons-ui`: update the import to import {
BuildStatus } from '@gridsuite/commons-ui' instead of BUILD_STATUS from
'./network/constants', then update the SecurityAnalysisParametersInline code
that references BUILD_STATUS (lines around the SecurityAnalysisParametersInline
component) to use BuildStatus (matching the enum/shape exported by commons-ui)
so the component aligns with the other migrated files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6d80b43d-adee-4a6d-a9cf-fa013c343f01

📥 Commits

Reviewing files that changed from the base of the PR and between 55f2dd0 and b4c31d7.

📒 Files selected for processing (16)
  • src/components/graph/menus/create-node-menu.tsx
  • src/components/graph/menus/root-network/unbuild-all-nodes-button.tsx
  • src/components/graph/network-modification-tree-model.ts
  • src/components/graph/nodes/build-button.tsx
  • src/components/graph/nodes/build-status-chip.tsx
  • src/components/graph/nodes/network-modification-node.tsx
  • src/components/graph/tree-node.type.ts
  • src/components/graph/util/model-functions.ts
  • src/components/network-modification-tree-pane.jsx
  • src/components/network/constants.ts
  • src/components/parameters-tabs.tsx
  • src/components/results/common/computation-report-viewer.tsx
  • src/components/study-container.jsx
  • src/services/study/tree-subtree.ts
  • src/translations/en.json
  • src/translations/fr.json
💤 Files with no reviewable changes (4)
  • src/components/network/constants.ts
  • src/translations/en.json
  • src/translations/fr.json
  • src/components/graph/nodes/build-status-chip.tsx

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/components/parameters-tabs.tsx (1)

91-91: Use currentNodeBuildStatus directly to avoid unnecessary callback invalidation

displayTab now depends on the full currentNode object only to read globalBuildStatus. Since currentTreeNode is frequently recreated as a new object reference, this causes avoidable useCallback churn. Passing currentNodeBuildStatus directly keeps this stable and simpler.

Refactor sketch
-    const currentNode = useSelector((state: AppState) => state.currentTreeNode ?? null);
     const currentNodeUuid = useSelector((state: AppState) => state.currentTreeNode?.id ?? null);
     const currentNodeBuildStatus = useSelector((state: AppState) => state.currentTreeNode?.data.globalBuildStatus);
@@
-                        globalBuildStatus={currentNode?.data?.globalBuildStatus}
+                        globalBuildStatus={currentNodeBuildStatus}
@@
-        currentNode,
         tabValue,
@@
         currentNodeBuildStatus,

Also applies to: 334-334, 399-399

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/parameters-tabs.tsx` at line 91, The displayTab callback
currently depends on the full currentTreeNode object (selected via const
currentNode = useSelector((state: AppState) => state.currentTreeNode ?? null)),
causing unnecessary invalidation when the node object reference changes; change
the selector to pull only the primitive/currentNodeBuildStatus (e.g., const
currentNodeBuildStatus = useSelector((s: AppState) =>
s.currentTreeNode?.globalBuildStatus ?? null)) and update displayTab and any
other callbacks that only need globalBuildStatus to depend on
currentNodeBuildStatus instead of currentNode; apply the same change to the
other occurrences noted (the selectors/usages around the displayTab-like
callbacks at the locations referenced) so callbacks remain stable and avoid
churn.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/parameters-tabs.tsx`:
- Around line 319-320: The current check using negations allows undefined to be
treated as "built"; update the isBuiltCurrentNode logic to explicitly check for
the built state(s) rather than relying on !== comparisons. Replace the
expression using currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
currentNodeBuildStatus !== BuildStatus.BUILDING with an explicit equality check
(e.g., currentNodeBuildStatus === BuildStatus.BUILT or currentNodeBuildStatus
=== <other explicit built enum>) so that undefined or unknown statuses evaluate
to false; adjust any usage inside ParametersTabs (or the isBuiltCurrentNode
variable) accordingly.

---

Nitpick comments:
In `@src/components/parameters-tabs.tsx`:
- Line 91: The displayTab callback currently depends on the full currentTreeNode
object (selected via const currentNode = useSelector((state: AppState) =>
state.currentTreeNode ?? null)), causing unnecessary invalidation when the node
object reference changes; change the selector to pull only the
primitive/currentNodeBuildStatus (e.g., const currentNodeBuildStatus =
useSelector((s: AppState) => s.currentTreeNode?.globalBuildStatus ?? null)) and
update displayTab and any other callbacks that only need globalBuildStatus to
depend on currentNodeBuildStatus instead of currentNode; apply the same change
to the other occurrences noted (the selectors/usages around the displayTab-like
callbacks at the locations referenced) so callbacks remain stable and avoid
churn.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f1fd5b63-60bf-47c7-ab11-5b8b98781a78

📥 Commits

Reviewing files that changed from the base of the PR and between b4c31d7 and e9a72ae.

📒 Files selected for processing (1)
  • src/components/parameters-tabs.tsx

Comment on lines +319 to +320
currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
currentNodeBuildStatus !== BuildStatus.BUILDING
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

isBuiltCurrentNode currently treats unknown status as built

Because globalBuildStatus is optional, undefined can reach this check and evaluates to true with the current negated comparisons. That can enable Security Analysis on nodes with unknown build state.

Proposed fix
                         isBuiltCurrentNode={
-                            currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
-                            currentNodeBuildStatus !== BuildStatus.BUILDING
+                            currentNodeBuildStatus != null &&
+                            currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
+                            currentNodeBuildStatus !== BuildStatus.BUILDING
                         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
currentNodeBuildStatus !== BuildStatus.BUILDING
currentNodeBuildStatus != null &&
currentNodeBuildStatus !== BuildStatus.NOT_BUILT &&
currentNodeBuildStatus !== BuildStatus.BUILDING
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/parameters-tabs.tsx` around lines 319 - 320, The current check
using negations allows undefined to be treated as "built"; update the
isBuiltCurrentNode logic to explicitly check for the built state(s) rather than
relying on !== comparisons. Replace the expression using currentNodeBuildStatus
!== BuildStatus.NOT_BUILT && currentNodeBuildStatus !== BuildStatus.BUILDING
with an explicit equality check (e.g., currentNodeBuildStatus ===
BuildStatus.BUILT or currentNodeBuildStatus === <other explicit built enum>) so
that undefined or unknown statuses evaluate to false; adjust any usage inside
ParametersTabs (or the isBuiltCurrentNode variable) accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants